import request from '@/utils/request'
import { encryptionData } from '@/utils/com'
import Qs from 'qs'

/* 获取采购订单列表 */
export function getOrderList(data) {
  return request({
    url: '/jcdOrder/purchaseOrder/page',
    method: 'get',
    headers: encryptionData(data, '/purchaseOrder/page'),
    params: data
  })
}


/* 确认订单 */
export function affirmOrder(data) {
  return request({
    url: '/jcdOrder/purchaseOrder/confirmOrder',
    method: 'post',
    headers: encryptionData(data, '/purchaseOrder/confirmOrder'),
    data: Qs.stringify(data)
  })
}
/* 手动分佣 */
export function makeOrderDivide(data) {
  return request({
    url: '/jcdOrder/divideOrder/makeOrderDivide',
    method: 'post',
    headers: encryptionData(data, '/divideOrder/makeOrderDivide'),
    data: Qs.stringify(data)
  })
}

/* 上传节点图片*/
export function uploadNodeFile(data) {
  return request({
    url: '/jcdOrder/jcdServiceOrderNodeData/update',
    method: 'put',
    headers: encryptionData(data, '/jcdServiceOrderNodeData/update'),
    data: Qs.stringify(data)
  })
}

/* 节点验收 */
export function setNodeStatus(data) {
  return request({
    url: `/jcdOrder/jcdServiceOrderNodeData/nodeAcceptance/${data.id}`,
    method: 'post',
    headers: encryptionData(data, `/jcdServiceOrderNodeData/nodeAcceptance/${data.id}`),
    data: Qs.stringify(data)
  })
}

/* 发起质保 */
export function doWarranty(data) {
  return request({
    url: `/jcdOrder/purchaseOrder/doWarranty/${data.id}`,
    method: 'post',
    headers: encryptionData(data, `/doWarranty/${data.id}`),
    data: Qs.stringify(data)
  })
}


/* 确认发货 */
export function orderSendOut(data) {
  return request({
    url: '/jcdOrder/purchaseOrder/confirmShipment',
    method: 'post',
    headers: encryptionData(data, '/purchaseOrder/confirmShipment'),
    data: Qs.stringify(data)
  })
}

/* 删除订单 */
export function deleteOrder(id, data) {
  return request({
    url: `/jcdOrder/purchaseOrder/delete/${id}`,
    method: 'delete',
    headers: encryptionData(data, `/purchaseOrder/delete/${id}`)
  })
}

/* 获取采购清单 */
export function getOrderDetail(data) {
  return request({
    url: `/jcdOrder/purchaseOrderData/get/byOrderId/${data.id}`,
    method: 'get',
    headers: encryptionData(data, `/purchaseOrderData/get/byOrderId/${data.id}`)
  })
}

/* 修改订单 */
export function updateOrder(data) {
  return request({
    url: '/jcdOrder/purchaseOrder/update',
    method: 'PUT',
    headers: encryptionData(data, '/purchaseOrder/update'),
    data: Qs.stringify(data)
  })
}

/* 修改产品 */
export function updateOrderProduct(data) {
  return request({
    // url: '/jcdOrder/purchaseOrderData/update',
    url: '/jcdOrder/purchaseOrder/editOrderSku',
    method: 'PUT',
    headers: encryptionData(data, '/purchaseOrder/editOrderSku'),
    data: Qs.stringify(data)
  })
}

/* 修改补差价产品 */
export function updateOrderTemProduct(data) {
  return request({
    url: '/jcdGys/updateOrderTemProduct',
    method: 'post',
    headers: encryptionData(data, '/merchantBrand/page'),
    data: Qs.stringify(data)
  })
}

/* 修改服务费 */
export function updateServiceMoney(data) {
  return request({
    url: '/jcdOrder/purchaseOrder/editOrderServiceMoney',
    method: 'put',
    headers: encryptionData(data, '/purchaseOrder/editOrderServiceMoney'),
    data: Qs.stringify(data)
  })
}

/* 删除产品 */
export function deleteOrderProduct(data) {
  return request({
    // url: `/jcdOrder/purchaseTempMaterials/delete/${dataId}/${orderId}`,
    url: `/jcdOrder/purchaseOrder/deleteOrderData`,
    method: 'delete',
    headers: encryptionData(data, `/purchaseOrder/deleteOrderData`),
    data: Qs.stringify(data)
  })
}

/* 删除补差价产品 */
export function deleteTempOrderProduct(dataId, orderId, data) {
  return request({
    url: `/jcdOrder/purchaseTempMaterials/delete/${dataId}/${orderId}`,
    method: 'delete',
    headers: encryptionData(data, `/purchaseTempMaterials/delete/${dataId}/${orderId}`)
  })
}

/* 获取产品列表 */
export function getProductList(data) {
  return request({
    url: '/jcdGys/jcdMaterialsSku/querySkuMaterialsPage',
    method: 'get',
    headers: encryptionData(data, '/jcdMaterialsSku/querySkuMaterialsPage'),
    params: data
  })
}

/* 添加产品 */
export function addOrderProduct(data) {
  return request({
    url: '/jcdOrder/purchaseOrder/addSkuOrderOper',
    method: 'post',
    headers: encryptionData(data, '/purchaseOrder/addSkuOrderOper'),
    data: Qs.stringify(data)
  })
}

/* 添加补差价产品 */
export function addOrderTemProduct(data) {
  return request({
    url: '/jcdOrder/purchaseTempMaterials/save',
    method: 'post',
    headers: encryptionData(data, '/purchaseTempMaterials/save'),
    data: Qs.stringify(data)
  })
}

